// app/controller/topics.js
const Controller = require('egg').Controller

class SupplierController extends Controller {
  async getSupplierInfoByBody() {
    const { ctx } = this
    const supplierInfo = await ctx.service.supplier.getSupplierInfoByBody(ctx.request.body)
    ctx.body = supplierInfo
  }

  async exportExcel() {
    const { ctx } = this
    const res = await ctx.service.supplier.exportExcel(ctx.request.body)
    ctx.header['content-type'] = 'application/vnd.openxmlformats'
    ctx.set('Content-Disposition', "attachment;filename*=utf-8' '" + encodeURIComponent('供应商列表') + '.xlsx')
    ctx.body = res
  }

  // 保存接口
  async saveSupplierInfoByBody() {
    const { ctx } = this
    ctx.body = await ctx.service.supplier.saveSupplierInfoByBody(ctx.request.body)
  }

  // 删除接口
  async deleteSupplierInfoByBody() {
    const { ctx } = this
    ctx.body = await ctx.service.supplier.deleteSupplierInfoByBody(ctx.request.body)
  }
}
module.exports = SupplierController
